package com.ruoyi.shop.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.shop.domain.Dshop;
import com.ruoyi.shop.service.IDshopService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 标签商品中间Controller
 * 
 * @author ruoyi
 * @date 2025-06-20
 */
@RestController
@RequestMapping("/shop/dshop")
public class DshopController extends BaseController
{
    @Autowired
    private IDshopService dshopService;

    /**
     * 查询标签商品中间列表
     */
    @PreAuthorize("@ss.hasPermi('shop:dshop:list')")
    @GetMapping("/list")
    public TableDataInfo list(Dshop dshop)
    {
        startPage();
        List<Dshop> list = dshopService.selectDshopList(dshop);
        return getDataTable(list);
    }

    /**
     * 导出标签商品中间列表
     */
    @PreAuthorize("@ss.hasPermi('shop:dshop:export')")
    @Log(title = "标签商品中间", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Dshop dshop)
    {
        List<Dshop> list = dshopService.selectDshopList(dshop);
        ExcelUtil<Dshop> util = new ExcelUtil<Dshop>(Dshop.class);
        util.exportExcel(response, list, "标签商品中间数据");
    }

    /**
     * 获取标签商品中间详细信息
     */
    @PreAuthorize("@ss.hasPermi('shop:dshop:query')")
    @GetMapping(value = "/{dshopId}")
    public AjaxResult getInfo(@PathVariable("dshopId") Long dshopId)
    {
        return success(dshopService.selectDshopByDshopId(dshopId));
    }

    /**
     * 新增标签商品中间
     */
    @PreAuthorize("@ss.hasPermi('shop:dshop:add')")
    @Log(title = "标签商品中间", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Dshop dshop)
    {
        return toAjax(dshopService.insertDshop(dshop));
    }

    /**
     * 修改标签商品中间
     */
    @PreAuthorize("@ss.hasPermi('shop:dshop:edit')")
    @Log(title = "标签商品中间", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Dshop dshop)
    {
        return toAjax(dshopService.updateDshop(dshop));
    }

    /**
     * 删除标签商品中间
     */
    @PreAuthorize("@ss.hasPermi('shop:dshop:remove')")
    @Log(title = "标签商品中间", businessType = BusinessType.DELETE)
	@DeleteMapping("/{dshopIds}")
    public AjaxResult remove(@PathVariable Long[] dshopIds)
    {
        return toAjax(dshopService.deleteDshopByDshopIds(dshopIds));
    }
}
